﻿package com.sxhalo.manage.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.sxhalo.manage.dao.SysOperationDAO;
import com.sxhalo.manage.map.SysOperation;
import com.sxhalo.manage.service.IBaseService;
import com.sxhalo.manage.utils.Pager;

public class SysOperationServiceImpl implements IBaseService<SysOperation> {

	private SysOperationDAO myDao;

	public SysOperationDAO getMyDao() {
		return myDao;
	}

	public void setMyDao(SysOperationDAO myDao) {
		this.myDao = myDao;
	}

	@Override
	public void save(SysOperation entity) {
		myDao.save(entity);
	}

	@Override
	public void update(SysOperation entity) {
		myDao.merge(entity);
	}

	@Override
	public Boolean delete(SysOperation entity) {
		try {
			myDao.delete(entity);
		} catch (Exception e) {
			return false;
		}
		return true;
	}

	@Override
	public Boolean delete(Integer id) {
		try {
			SysOperation entity = new SysOperation();
			entity.setOperationId(id);
			myDao.delete(entity);
		} catch (Exception e) {
			return false;
		}
		return true;
	}

	@Override
	public void service() {

	}

	@Override
	public SysOperation findById(Object id) {
		return myDao.findById(Integer.parseInt(id.toString()));
	}

	@Override
	public SysOperation find(String fieldName, Object fieldValue) {
		List<SysOperation> list = findList(fieldName, fieldValue);
		return list.size() > 0 ? list.get(0) : null;
	}

	@Override
	public List<SysOperation> findList(String fieldName, Object fieldValue) {
		return myDao.findByProperty(fieldName, fieldValue);
	}

	@Override
	public List<SysOperation> findAll() {
		return myDao.findAll();
	}

	@Override
	public List<SysOperation> findListByIds(List<String> idList) {
		List<SysOperation> list = new ArrayList<SysOperation>();
		for (String id : idList) {
			SysOperation po = findById(Integer.parseInt(id));
			if (po != null) {
				list.add(po);
			}
		}
		return list.size() > 0 ? list : null;
	}

	@Override
	public Pager<SysOperation> findPagerList(int pageNumber, int pageSize,
			String whereStr, String orderStr) {
		return myDao.findPagerList(pageNumber, pageSize, whereStr);
	}

	@Override
	public List<SysOperation> findByExample(Object instance) {
		// TODO Auto-generated method stub
		return null;
	}
}
